﻿using Volo.Abp.DependencyInjection;
using YAPACS.Organizations;
using YAPACS.Workflows;

namespace YAPACS.RisServer.Workflows.Statistic;

public class AdvancedSearchExpression : WorkflowBase, IAdvancedSearchExpression, ITransientDependency
{
    protected override async Task<WorkflowOutput> InvokeCoreAsync(WorkflowInput input)
    {
        DateTime startTime= DateTime.Today.AddDays(-2), endTime= DateTime.Today;
        //检查时间（范围）//创建时间
        if (input.GetValueOrDefault("examTimeRange") is string value)
        {
            if (!string.IsNullOrWhiteSpace(value))
            {
                var timeRange = value.Split(',');
                startTime = DateTime.Parse(timeRange[0]).Date;
                endTime = DateTime.Parse(timeRange[1]).AddDays(1).Date;
            }
        }
        return await Task.FromResult(new WorkflowOutput
        {
            Success = true,
            Data=new {
                StartTime = startTime,
                EndTime= endTime,
                DeviceTypeId= input["deviceTypeId"],
                DepartmentId = input["departmentId"]
            }
        });
    }
}
